<%-- 
    Document   : autoPrint
    Created on : 2017-3-29, 14:09:28
    Author     : 52461
--%>

<%@page import="com.cxhd.lis.DataCache"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../link2.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       

<script type="text/javascript" src="${base}/js/angular-base.js"></script>
        <script type="text/javascript" src="${base}/js/highcharts/highcharts.js" ></script>
        <script type="text/javascript" src="${base}/js/mychartoption.js" ></script>
        
        <title id="title"></title>
        <style>
            * { margin:0; padding:0;}
            body { margin:0; padding:0;  font-family:"微软雅黑";}
            table td { padding:1px 1px;}
            .title { font-size:24px; text-align:center; width:40%;}
            .check_info th { border-bottom:1px #666 solid; padding-bottom:5px;}
            /*.check_info td,th{ padding-left:20px;}*/
            .hx{ border-right:  1px #666 solid}
             .s-warning{
        color:red;
    }
    .s-danger{
        color:blue;
    }      
    .s_warning{
        color:red;
    }
    .s_danger{
        color:blue;
    }    
    .warning{
        color:red;
    }
    .danger{
        color:blue;
    }
        </style>
    </head>
    <body ng-app="autoPrint" ng-controller="mainCtrls">
        <table width="1000px" style=" margin:0 auto;font-size:{{fontSize}}" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="2">
                    <div style="text-align: center">
                        <h4 style="font-weight: bold;font-size: 24px;" ng-bind="reportName"></h4>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2"> 
                    <table cellpadding="0" cellspacing="0" width="100%" style=" border-bottom:1px #666 solid;font-size:{{fontSize}}">
                        <tr>
                            <td  style="font-weight: bold;" align="right" width="80px">姓名：</td>
                            <td style="font-weight: bold;" contenteditable="true" align="left" width="100px">{{info.PATIENTNAME}}</td>
                            <td align="right">病历号：</td>
                            <td contenteditable="true" align="left" width="100px">{{info.PATIENTID}}</td>
                            <td align="right">科室：</td>
                            <td contenteditable="true" align="left" width="100px">{{info.SECTION}}</td>
                            <td align="right">样本号：</td>
                            <td contenteditable="true" align="left" width="120px">{{info.SAMPLENO}}</td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold;" align="right">性别：</td>
                            <td style="font-weight: bold;" contenteditable="true" align="left">{{info.SEX}}</td>
                            <!--                            <td align="right">病房号：</td>
                                                        <td contenteditable="true" align="left"></td>-->
                            <td align="right">床号：</td>
                            <td contenteditable="true" align="left">{{info.BED_NO}}</td>
                            <td align="right">送检医生：</td>
                            <td contenteditable="true" align="left">{{info.SJYS}}</td>
                            <td align="right">临床诊断：</td>
                            <td contenteditable="true" align="left">{{info.DIAGNOSTIC}}</td>
                        </tr>
                        <tr>
                            <td style="font-weight: bold;" align="right">年龄：</td>
                            <td style="font-weight: bold;" contenteditable="true" align="left">{{info.AGE}}</td>
                            <td align="right">送检时间：</td>
                            <td  >{{info.CUSTOM1}}</td>
                            <!--                            <td contenteditable="true" align="left">{{info.BED_NO}}</td>
                            -->                            <td align="right">机器型号：</td>
                            <td contenteditable="true" align="left">{{results[0].DEVICEID}}</td>
                            <td align="right">备注：</td>
                            <td contenteditable="true" align="left">{{info.CUSTOM2}}</td>
                            <!--<td contenteditable="true" align="left">{{info.EXAMINAIM}}</td>-->
                        </tr>
                    </table>
                </td>
            </tr>
            <tr style="border-bottom:1px #666 solid;height:430px;">
                <td colspan="2" valign="top">
                    <!--                    普通报告-->
                    <table width="100%" ng-if="type == '1'">
                        <tr>
                            <td valign="top"  style=" padding-right:0;">
                                <table cellpadding="0" cellspacing="0" width="100%" class="check_info" style="font-size:{{fontSize}}">

                                    <tr>
                                        <th align="left">项目简称</th>
                                        <th align="left">项目名称</th>

                                        <th></th>
                                        <th align="left">结果</th>

                                        <th align="left">单位</th>
                                        <th align="left">参考范围</th>
                                    </tr>


                                    <tr ng-repeat="le in left| filter:{RESULTFLAG:'0'}" ng-class="{true: 's-danger', false: 's-warning'}[le.isActive]">
                                        <!--<td>{{$index+1}}</td>-->
                                        <td>{{le.TESTID}}</td>
                                        <td>{{le.CHINESENAME}}</td>
                                        <td>{{le.HL_STATUS}}</td>
                                        <td>{{le.TESTRESULT}}</td>

                                        <td>{{le.UNIT}}</td>
                                        <td ng-class="{true: 'hx', false: 'inactive'}['isActive']">{{le.fanwei}}</td>
                                    </tr>

                                </table>
                            </td>
                            <td valign="top" style="padding-left:0; margin:0;" ng-show="fenye" id="fenye">
                                <table cellpadding="0" cellspacing="0" width="100%" class="check_info" style="margin-left: 5px;font-size:{{fontSize}}">
                                    <thead>
                                        <tr>
                                            <th align="left">项目简称</th>
                                            <th align="left">项目名称</th>
                                            <th></th>
                                            <th align="left">结果</th>

                                            <th align="left">单位</th>
                                            <th align="left">参考范围</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="ri in right| filter:{RESULTFLAG:'0'}" ng-class="{true: 's-danger', false: 's-warning'}[ri.isActive]">
                                            <!--<td>{{$index+15}}</td>-->
                                            <td>{{ri.TESTID}}</td>
                                            <td>{{ri.CHINESENAME}}</td>
                                            <td>{{ri.HL_STATUS}}</td>
                                            <td>{{ri.TESTRESULT}}</td>

                                            <td>{{ri.UNIT}}</td>
                                            <td>{{ri.fanwei}}</td>
                                        </tr>
                                    </tbody>
                                </table>



                            </td>
                        </tr>
                    </table>
                    <!--                    特殊模板报告-->
                    <table width="100%" ng-if="type == '2'">
                        <tr>
                            <td valign="top" width="50%"  style=" padding-right:0;border-right: 1px #000 solid">
                                <table cellpadding="0" cellspacing="0" width="100%" class="check_info" style="font-size:{{fontSize}}; border-bottom: 1px #000 solid" >
                                    <thead>
                                        <tr>
                                            <th align="left">项目简称</th>
                                            <th align="left">项目名称</th>

                                            <th></th>
                                            <th align="left">结果</th>

                                            <th align="left">单位</th>
                                            <th align="left">参考范围</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="le in left| filter:{RESULTFLAG:'0'}" ng-class="{true: 's-danger', false: 's-warning'}[le.isActive]">
<!--                                            <td>{{$index + 1}}</td>-->
                                            <td>{{le.TESTID}}</td>
                                            <td>{{le.CHINESENAME}}</td>
                                            <td>{{le.HL_STATUS}}</td>
                                            <td>{{le.TESTRESULT}}</td>

                                            <td>{{le.UNIT}}</td>
                                            <td ng-class="{
                                                                true: 'hx', false: 'inactive'}
                                                ['isActive']">{{le.fanwei}}</td>
                                        </tr>
                                    </tbody>
                                </table>
                                <table  cellpadding="0" cellspacing="0" width="100%" style="font-size:{{fontSize}}">
                                    <tr style="border-bottom: 1px #000 solid">
                                        <td align="left">
                                            尿理学指标
                                        </td>
                                        <td>
                                            颜色:{{results[25].TESTRESULT}}</br>
                                            浊度:{{results[26].TESTRESULT}}
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left">
                                            尿红细胞形态学指标
                                        </td>
                                        <td>
                                            正常红细胞（%）:{{results[27].TESTRESULT}}（%）</br>
                                            异常红细胞（%）:{{results[28].TESTRESULT}}（%）
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td valign="top" style="padding-left:0; margin:0;" ng-show="fenye2" id="fenye2">
                                <table cellpadding="0" cellspacing="0" width="100%" class="check_info" style="margin-left: 5px;font-size:{{fontSize}}">
                                    <thead>
                                        <tr>
                                            <th align="left">项目简称</th>
                                            <th align="left">项目名称</th>
                                            <th></th>
                                            <th align="left">结果</th>

                                            <th align="left">单位</th>
                                            <th align="left">参考范围</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr ng-repeat="ri in right| filter:{RESULTFLAG:'0'}" ng-class="{true: 's-danger', false: 's-warning'}[ri.isActive]">
<!--                                            <td>{{$index + 15}}</td>-->
                                            <td>{{ri.TESTID}}</td>
                                            <td>{{ri.CHINESENAME}}</td>
                                            <td>{{ri.HL_STATUS}}</td>
                                            <td>{{ri.TESTRESULT}}</td>

                                            <td>{{ri.UNIT}}</td>
                                            <td>{{ri.fanwei}}</td>
                                        </tr>
                                    </tbody>
                                </table>



                            </td>
                        </tr>
                    </table>



                    <div ng-show="chart" style="position:relative; bottom: -20px;margin-top: -30px; ">

                        <div ng-show="sh_baso" id="baso"  style="float: left;width:170px;height: 170px;">></div>
                        <div ng-show="sh_diff" id="diff"  style="float: left;width:170px;height: 170px;"></div>

                        <div ng-show="sh_wbc" id="wbc"  style="float: left;width:230px;height: 170px;"></div>
                        <div ng-show="sh_rbc" id="rbc"  style="float: left;width:230px;height: 170px;"></div>
                        <div ng-show="sh_plt" id="plt"  style="float: left;width:230px;height: 170px;"></div>


                        <div style="clear: both"></div>
                    </div>

                    <div ng-show="zftchart">
                        <div ng-show="sh_wbc" style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>WBC</div>
                            <img ng-src="{{WBC}}" height="{{imageHeight}}" />
                        </div>

                        <div ng-show="sh_rbc"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>RBC</div>
                            <img ng-src="{{RBC}}" height="{{imageHeight}}" />
                        </div>
                        <div ng-show="sh_diff"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>DIFF</div>
                            <img ng-src="{{DIFF}}" height="{{imageHeight}}"/>
                        </div>
                        <div ng-show="sh_baso"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>BASO</div>
                            <img ng-src="{{BASO}}" height="{{imageHeight}}"/>
                        </div>

                        <div ng-show="sh_plt"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>PLT</div>
                            <img ng-src="{{PLT}}" height="{{imageHeight}}" />
                        </div>
                        <div  ng-show="sh_sret"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>SRET</div>
                            <img ng-src="{{SRET}}" height="{{imageHeight}}" />
                        </div>
                        <div  ng-show="sh_swdf"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>SWDF</div>
                            <img ng-src="{{SWDF}}" height="{{imageHeight}}"/>
                        </div>
                        <div  ng-show="sh_swnr"  style="float: left;width:{{imageWidth}};height: 140px;margin-left: 10px;">
                            <div>SWNR</div>
                            <img ng-src="{{SWNR}}" height="{{imageHeight}}" />
                        </div>
                        <div style="clear: both"></div>
                    </div>
                    <div ng-show="image_more">
                        <div ng-repeat="image in moreImage" style="float: left;margin-left: 10px;">
                            <img height="110px" ng-src="{{image}}" />
                        </div>
                        <div style="clear: both"></div>
                    </div>
                </td>
            </tr>

            <tr>
                <td colspan="2">
                    <table style="font-size:{{fontSize}}" width="100%">
                        <tr>

                            <td style="white-space: nowrap" align="left" width="80px">报告日期：</td>
                            <td style="white-space: nowrap" contenteditable="true" align="left" width="260px">{{date}}</td>

                            <td style="white-space: nowrap" align="left" width="200px">检验医生<span style="margin-left: 10px;margin-right: 10px;">:</span>{{info.JYYS}}</td>

                            <td style="white-space: nowrap" colspan="" align="right" width="120px">审核人：</td>
                            <td style="white-space: nowrap"  contenteditable="true" align="left" width="100px">
                            <span ng-hide="sign">{{info.CHECKOPERATOR}}</span>
                                <img style="position: fixed" height="40px" ng-show="sign" ng-src="{{sign}}">
                            </td>
                        </tr>
                        <tr>

                            <td colspan="4" align="left" width="120px">注：此结果仅对本份检验标本负责 </td>


                            <td align="right" width="200px"></td>

                        </tr>
                    </table>
                </td>

            </tr>

        </table>

    </body>
</html>
<script>

    angular.module("autoPrint", ['baseModule'])

            .controller("mainCtrls", function ($scope, base) {
                var WBC = [];
                var RBC = [];
                var PLT = [];
                var BASO = [];
                var DIFF = [];
                var SRET = [];
                var SWDF = [];
                var SWNR = [];
                $scope.config = {};
                $scope.fontSize = "16px";
                $scope.imageWidth = "230px";
                $scope.imageHeight = "100px";
                $scope.d_imageHeight = "120px";
                 $scope.date = new Date().Format("yyyy-MM-dd hh:mm:ss");;
                $scope.reportName = "<%=DataCache.getIntance().getConfig().get("hospitalName")%>检验报告单";
                console.log('<%=DataCache.getIntance().getConfig().get("hospitalName")%>');
                var rptQueue = JSON.parse(window.localStorage.rpts);
                var uuid = rptQueue.shift();
                window.localStorage.rpts = JSON.stringify(rptQueue);
                //var uuid = "c9b928e315c193c4f98d8b680e495f8f";
                $scope.type="1";  
                var queryInfo = function () {
                    base.post("queryInfoRpt", {uuid: uuid}).get(function (data) {
                        console.log(data);
                        if(data!="false"){
                            var s=0;
                            for( i in  data.results){
                                var test_id = data.results[i].TESTID;
                                if (test_id && test_id.indexOf('image') > -1) {
                                        s++;
                                    }
                                }
                            if(s>4){
                                  $scope.imageWidth = "180px";
                                  $scope.imageHeight="120px";
                            }
                            var deviceId = data.results[0].DEVICEID;
                            if(deviceId=='AVE-752'){
                              $scope.type="2";  
                            }
                             for (var i in data.results) {
                                if (!data.results[i].index) {
                                data.results[i].index = 999;
                                }
                            }
                            data.results.sort(function (a, b) {
                                return a.index - b.index;
                            });
                            $scope.info = data.info;
                            if(data.config){
                            $scope.config = angular.fromJson(unescape(data.config));
                             if ($scope.config&&$scope.config.reportName != "") {
                                $scope.reportName = $scope.config.reportName;
                              }
                              if ($scope.config&&$scope.config.fontSize != "") {
                                $scope.fontSize = $scope.config.fontSize;
                              }
                              console.log($scope.reportName);
                          }
                            checkChart(data.results);
                            changeSex(data.results,data.info.SEX);
                            checkRange(data.results);
                            handlerResult(data.results);
                            
                             //获取审核医生签名
                            base.post("getSign",{name:$scope.info.CHECKOPERATOR}).get(function(data){
                                if(data!='false'){
                                    $scope.sign = data;
                                }
                                   setTimeout(function(){
                                        window.print();
                                        if(rptQueue.length>0){
                                            location = location;
                                         }
                                        else{
                                            window.close();
                                         }
                                    },800)
                            })                            
                          
                        }else{
                             location = location;
                        }
                        
                       
               
                    });
                }
               var checkChart = function (data) {
                   $scope.copyResult = angular.copy(data);
                    $scope.moreImage=[];
       
                for (var i = 0; i < $scope.copyResult.length; i++) {
                    if ($scope.copyResult[i].RESULTFLAG == "4") {
                        $scope.moreImage.push("data:image/jpg;base64," + $scope.copyResult[i].TESTRESULT);
                    }
                    if ($scope.copyResult[i].TESTID == 'image#WBC') {
                        $scope.sh_wbc=true;
                       
                        if($scope.copyResult[i].RESULTFLAG=='2'){
                    
                        WBC = $scope.copyResult[i].TESTRESULT.toString();
                   
                         }
                    else if ($scope.copyResult[i].RESULTFLAG == '3') {
                         $scope.chart = true;
                        var wbcs = $scope.copyResult[i].TESTRESULT.split(",");
                          for (s in wbcs) {
                                WBC.push([parseFloat($.trim(wbcs[s]).split(" ")[0]), parseFloat($.trim(wbcs[s]).split(" ")[1])]);
                           }
                        }
                    else{
                         $scope.chart = true;
                        WBC = $scope.copyResult[i].TESTRESULT.toString().split(" ");
                       }
               
                    } else if ($scope.copyResult[i].TESTID.toString() == 'image#RBC') {
                            $scope.sh_rbc=true;
                            if($scope.copyResult[i].RESULTFLAG=='2'){   
                    
                            RBC = $scope.copyResult[i].TESTRESULT.toString();
                            }              
                            else{
                                RBC = $scope.copyResult[i].TESTRESULT.toString().split(" ");
                            }
              
                    } else if ($scope.copyResult[i].TESTID == 'image#PLT') {
                            $scope.sh_plt=true;
                        if($scope.copyResult[i].RESULTFLAG=='2'){
                    
                        PLT = $scope.copyResult[i].TESTRESULT.toString();
                        }
                        else{
                            PLT = $scope.copyResult[i].TESTRESULT.toString().split(" ");
                        }
               
                //  $scope.results.splice(i,1);
                        }
                    else if ($scope.copyResult[i].TESTID == 'image#DIFF') {
                            $scope.sh_diff=true;
                        if($scope.copyResult[i].RESULTFLAG=='2'){
                    
                            DIFF = $scope.copyResult[i].TESTRESULT.toString();
                         }
                    else if ($scope.copyResult[i].RESULTFLAG == '3') {
                         $scope.chart = true;
                        var diffs = $scope.copyResult[i].TESTRESULT.split(",");
                        for (s in diffs) {
                             DIFF.push([parseFloat($.trim(diffs[s]).split(" ")[0]), parseFloat($.trim(diffs[s]).split(" ")[1])]);
                            }
                        }
                    else{
                         $scope.chart = true;
                        DIFF = $scope.copyResult[i].TESTRESULT.toString().split(" ");
                    }
               
                //  $scope.results.splice(i,1);
            }
            else if ($scope.copyResult[i].TESTID == 'image#BASO') {
                 $scope.sh_baso=true;
                 if ($scope.copyResult[i].RESULTFLAG == '3') {
                  var basos = $scope.copyResult[i].TESTRESULT.split(",");
                       for (s in basos) {
                             BASO.push([parseFloat($.trim(basos[s]).split(" ")[0]), parseFloat($.trim(basos[s]).split(" ")[1])]);
                            }
                        }
                        else if($scope.copyResult[i].RESULTFLAG=='2'){
                    
                     BASO = $scope.copyResult[i].TESTRESULT.toString();
                }

                }
              else if ($scope.copyResult[i].TESTID == 'image#SWDF') {
                    $scope.sh_swdf = true;
                    if ($scope.copyResult[i].RESULTFLAG == '2') {
                          SWDF = $scope.copyResult[i].TESTRESULT;
                        }

                    } else if ($scope.copyResult[i].TESTID == 'image#SWNR') {
                       $scope.sh_swnr = true;
                         if ($scope.copyResult[i].RESULTFLAG == '2') {
                            SWNR = $scope.copyResult[i].TESTRESULT;
                        }

                    } else if ($scope.copyResult[i].TESTID == 'image#SRET') {
                            $scope.sh_sret = true;
                        if ($scope.copyResult[i].RESULTFLAG == '2') {
                            SRET = $scope.copyResult[i].TESTRESULT;
                        }

                    }
                }
                
                 if ($scope.moreImage.length > 0) {
                    console.log($scope.moreImage.length);
                    $scope.image_more = true;
                    } else {
                   $scope.WBC = "";
                    $scope.RBC = "";
                    $scope.PLT = "";
                    $scope.BASO = "";
                    $scope.DIFF = "";
                     $scope.SWNR = "";
                    $scope.SWDF = "";
                    $scope.SRET = "";
                    if (typeof RBC == "string") {
                        $scope.WBC = "data:image/jpg;base64," + WBC;
                        $scope.RBC = "data:image/jpg;base64," + RBC;
                        $scope.PLT = "data:image/jpg;base64," + PLT;
                        $scope.BASO = "data:image/jpg;base64," + BASO;
                        $scope.DIFF = "data:image/jpg;base64," + DIFF;
                        $scope.SWNR = "data:image/jpg;base64," + SWNR;
                        $scope.SWDF = "data:image/jpg;base64," + SWDF;
                        $scope.SRET = "data:image/jpg;base64," + SRET;
                        $scope.zftchart = true;


                    } else {
                       
                        var NEWWBC = [], NEWRBC = [], NEWPLT = [];
                        if (RBC.length > 0) {
                            var WBCindexs = [];
                            for (var i in WBC) {
                               
                                if (WBC.length < 500) {
                                    WBCindexs.push(i);
                                    NEWWBC.push(parseFloat(WBC[i]));
                                }
                            }
                            var RBCindexs = [];
                            for (var i in RBC) {
                                RBCindexs.push(i);
                                NEWRBC.push(parseFloat(RBC[i]));
                            }
                            var PLTindexs = [];
                            for (var i in PLT) {
                                PLTindexs.push(i);
                                NEWPLT.push(parseFloat(PLT[i]));
                            }

                        }
                         
                        var baso = false;
                        for (var i in data) {
                            if (data[i].TESTID == "BASOR") {
                                baso = true;
                                break;
                            }
                        }
                        if (baso) {
                            $('#wbc').highcharts(getChart2("WBC/BASO", WBCindexs, NEWWBC));
                        } else {
                            //console.log(NEWWBC);
                            if (WBC.length > 500) {
                                $('#wbc').highcharts(getChart3("WBC", WBC));
                            } else {
                                $('#wbc').highcharts(getChart2("WBC", WBCindexs, NEWWBC));
                            }
                        }
                        //console.log(BASO);
                        if(BASO.length>0){
                             $('#baso').highcharts(getChart3("BASO", BASO));
                        }
                        if (DIFF.length > 0) {
                            $('#diff').highcharts(getChart3("DIFF", DIFF));
                        }

                        $('#rbc').highcharts(getChart2("RBC", RBCindexs, NEWRBC));
                        $('#plt').highcharts(getChart2("PLT", PLTindexs, NEWPLT,"PLT"));
                    }
                   }
                    

                }
                
                var checkRange = function (data) {
                   
                    if ($scope.info&&data&& $scope.info.AGE && $scope.info.SEX) {                      
                       
                        for (var i in data) {
                            if (data[i].ranges) {                               
                                var range = JSON.parse(unescape(data[i].ranges));
                                var item_range = checkAge_sex_range(data[i],range);
                               
                                if(item_range){
                                var lower = item_range.min_val;
                                var hight = item_range.max_val;
                                var lh = lower + "-" + hight;
                                data[i].fanwei = lh;
                                 if(lower&&hight){
                                              data[i].fanwei = lh;
                                        }
                                        else if(lower){
                                                data[i].fanwei = lower;
                                        }else if(hight){
                                                data[i].fanwei = lower;
                                        }
                                 if (parseFloat(data[i].TESTRESULT) < parseFloat(lower)) {
                                   
                                    data[i].isActive = true;
                                    data[i].HL_STATUS = "↓";
                                } else if (parseFloat(data[i].TESTRESULT) > parseFloat(hight)) {
                                    data[i].isActive = false;
                                    data[i].HL_STATUS = "↑";

                                }else{                                   
                                    data[i].isActive = null;
                                    data[i].HL_STATUS = "";
                                }
                            }
                            }
                            var k = 2;
                            if (data[i].Decimalplace) {
                                 k = data[i].Decimalplace;

                                   }
                           if(!isNaN(data[i].TESTRESULT)){      
                            data[i].TESTRESULT = parseFloat(data[i].TESTRESULT).toFixed(k);
                            }
                        }
                    }
                }
                
                var checkAge_sex_range = function(item,range){
                     var age = parseInt($scope.info.AGE);
                     //var item_range={};
                    for(var i in range){
                       
                        if(range[i].sex==$scope.info.SEX){
                           
                            if(range[i].max_age>=age&&age>=range[i].min_age){
                                return range[i];
                                break;
                            }
                        }
                    }
                }
                var changeSex = function (data,sex) {
                    if (sex && sex == '女') {
                        if (data) {
                            for (i in data) {
                                if (data[i].MREFLO0) {
                                    var lower = data[i].MREFLO0;
                                    var hight = data[i].MREFHI0;
                                    if (data[i].FREFLO0 && data[i].FREFLO0 != "") {
                                        lower = data[i].FREFLO0;
                                        hight = data[i].FREFHI0;
                                    }
                                    var lh = lower + "-" + hight;
                                    data[i].fanwei = lh;
                                    if(lower&&hight){
                                              data[i].fanwei = lh;
                                        }
                                        else if(lower){
                                                data[i].fanwei = lower;
                                        }else if(hight){
                                                data[i].fanwei = lower;
                                        }
                                    if (parseFloat(data[i].TESTRESULT) < parseFloat(lower)) {
                                        //console.log(data[i].TESTRESULT + "   " + data[i].MREFLO0);
                                        data[i].isActive = true;
                                        data[i].HL_STATUS = "↓"
                                    } else if (parseFloat(data[i].TESTRESULT) > parseFloat(hight)) {
                                        data[i].isActive = false;
                                        data[i].HL_STATUS = "↑"

                                    } else {
                                        data[i].isActive = null;
                                        data[i].HL_STATUS = "";
                                    }
                                }
                            }
                        }
                    } else {
                        if (data) {
                            for (i in data) {
                                if (data[i].MREFLO0) {
                                    var lower = data[i].MREFLO0;
                                    var hight = data[i].MREFHI0;

                                    var lh = lower + "-" + hight;
                                    data[i].fanwei = lh;
                                    if(lower&&hight){
                                              data[i].fanwei = lh;
                                        }
                                        else if(lower){
                                                data[i].fanwei = lower;
                                        }else if(hight){
                                                data[i].fanwei = lower;
                                        }
                                    if (parseFloat(data[i].TESTRESULT) < parseFloat(lower)) {
                                        //console.log(data[i].TESTRESULT + "   " + data[i].MREFLO0);
                                        data[i].isActive = true;
                                        data[i].HL_STATUS = "↓"
                                    } else if (parseFloat(data[i].TESTRESULT) > parseFloat(hight)) {
                                        data[i].isActive = false;
                                        data[i].HL_STATUS = "↑"

                                    } else {
                                        data[i].isActive = null;
                                        data[i].HL_STATUS = "";
                                    }
                                }
                            }
                        }
                    }
                }
               var newResult=[];
               $scope.left=[];
               $scope.right=[];
                var handlerResult = function(data){
                    if($scope.type=="2"){                        
                       if (data.length > 14) {
                            $scope.left = data.slice(0,11);
                            $scope.right = data.slice(11,25);
                            console.log($scope.left);
                            console.log($scope.right);
                            $scope.fenye2 = true;
                            console.log($("#fenye2").length+"--------------");
                            $("#fenye2").show();
                            $(".check_info").width("50%");
                            $("#hh").addClass("hx");
                            $scope.isActive = true;
                        } else {
                            for (var i = 0; i < data.length; i++) {
                                var l = data[i];
                                $scope.left.push(l);
                            }
                        }
                    }
                    
                    else{
                     for (var i = 0; i < data.length; i++) {
                       
                        if (data[i].TESTID.indexOf('image')<0) {
                            newResult.push(data[i]);
                            }
                        }
                     $scope.results =newResult;
                     if ($scope.results.length > 14) {
                        for (var i = 0; i < Math.ceil($scope.results.length / 2); i++) {
                                var l = $scope.results[i];
                                $scope.left.push(l);
                        }
            //console.log(Math.ceil($scope.results.length / 2)+'-------------------------')
            //console.table($scope.results);
                        for (var j = Math.ceil($scope.results.length / 2); j < $scope.results.length; j++) {
                                var r = $scope.results[j];
                                $scope.right.push(r);
                            }
                        console.log($scope.left);
                        console.log($scope.right);
                        $scope.fenye = true;
                        $("#fenye").show();
                        //$(".check_info").width("50%");
                        $("#hh").addClass("hx");
                        $scope.isActive = true;
                    } else {
                          for (var i = 0; i < $scope.results.length; i++) {
                               var l = $scope.results[i];
                                $scope.left.push(l);
                            }
                            }
                            
                    }
                }
                
                
                

                if (uuid) {
                    queryInfo();
                }
               




            })




</script>
